/**
 * File: 
 * Proj/Lab:
 * Author:
 * Date:
 * Section:
 * Email:
 */
package clientGUI.studentGUI;

import java.util.ArrayList;

import clientApp.*;

public class EditSemestersInPlan {

	public static Semester getSemester(Plan myPlan, String seasonSpaceYear)
	{
		String[] mySemData = seasonSpaceYear.split(" ");
		return getSemester(myPlan, mySemData[0], Integer.parseInt(mySemData[1]));
	}
	
	public static Semester getSemester(Plan myPlan, String season, int year)
	{
		return myPlan.getSemester(getSeasonInt(season), year);
	}
	
	public static String[] getSemesterSeasonsAndYears(Plan myPlan)
	{
		ArrayList<Semester> mySems = myPlan.getSemesters();
		String[] mySemesters = new String[mySems.size()];
		for(int i = 0; i != mySems.size(); i++)
		{
			Semester mySem = mySems.get(i);
			mySemesters[i] = getSeasonString(mySem.getSeason()) + " " + Integer.toString(mySem.getYear());
		}
		return mySemesters;
	}
	
	
	public static Semester addSemester(Plan myPlan, String season, int year)
	{
		Semester retSemester = new Semester(getSeasonInt(season), year);
		myPlan.addSemesterToPlan(retSemester);
		return retSemester;
	}
	
	public static void deleteSemester(Plan myPlan, String season, int year)
	{
		myPlan.deleteSemester(getSeasonInt(season), year);
	}
	
	public static String getSeasonString(int seasonConst)
	{
		if(seasonConst == ProjectConstants.FALL)
		{
			return "Fall";
		}
		else if(seasonConst == ProjectConstants.SPRING)
		{
			return "Spring";
		}
		else if(seasonConst == ProjectConstants.WINTER)
		{
			return "Winter";
		}
		else if(seasonConst == ProjectConstants.SUMMER)
		{
			return "Summer";
		}
		else
		{
			System.out.println("I done goofed\ngetseasonstring in editsemesters in plan");
			return null;
		}
	}
	
	public static int getSeasonInt(String season)
	{
		if(season.compareTo("FALL") == 0)
		{
			return ProjectConstants.FALL;
		}
		else if(season.compareTo("SPRING") == 0)
		{
			return ProjectConstants.SPRING;
		}
		else if(season.compareTo("WINTER") == 0)
		{
			return ProjectConstants.WINTER;
		}
		else if(season.compareTo("SUMMER") == 0)
		{
			return ProjectConstants.SUMMER;
		}
		else
		{
			System.out.println("I DONE GOOFED\nin edit semester in getSeasonInt");
			return -1;
		}
	}
	
	
	
	
}
